package coupon

import (
	// "bp/cache"
	sqlc "bp/db/sqlc"
	"bp/internal/util"
)

func (s *CouponEntityServiceImp) ConvToCouponIDs(i interface{}) []int64 {
	return util.MapToInt64(util.ToGenericSlice(i), func(v interface{}) int64 {
		switch t := v.(type) {
		case *sqlc.Coupon:
			return t.ID
		case *sqlc.ListCouponWithStatsRow:
			return t.ID
		}
		return 0
	})
}

func (s *CouponEntityServiceImp) MapCouponEntityToPtr(list []sqlc.Coupon) []*sqlc.Coupon {
	ptrs := make([]*sqlc.Coupon, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}

func (s *CouponEntityServiceImp) MapCouponWithStatEntityToPtr(list []sqlc.ListCouponWithStatsRow) []*sqlc.ListCouponWithStatsRow {
	ptrs := make([]*sqlc.ListCouponWithStatsRow, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}

func (s *CouponEntityServiceImp) MapCouponDistributionEntityToPtr(list []sqlc.CouponDistribution) []*sqlc.CouponDistribution {
	ptrs := make([]*sqlc.CouponDistribution, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}

func (s *CouponEntityServiceImp) MapCouponDistributionWithStatEntityToPtr(list []sqlc.ListCouponDistributionWithStatsByCouponIDAndIssuesAndDistributeScenesRow) []*sqlc.ListCouponDistributionWithStatsByCouponIDAndIssuesAndDistributeScenesRow {
	ptrs := make([]*sqlc.ListCouponDistributionWithStatsByCouponIDAndIssuesAndDistributeScenesRow, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}

func (s *CouponEntityServiceImp) MapCouponWithDistributionStatEntityToPtr(list []sqlc.ListCouponWithDistributionStatsByIssuerAndDistributeSceneRow) []*sqlc.ListCouponWithDistributionStatsByIssuerAndDistributeSceneRow {
	ptrs := make([]*sqlc.ListCouponWithDistributionStatsByIssuerAndDistributeSceneRow, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}

